ValentinaDB
Valentina database is designed to support Relational Model, which is a standard one for the last 10-15 years for DBMS world, and smoothly and natural extend it to Object-Relational model with powerful addition of Navigational Model elements! You can read the details at this article. A key advantage of object-relational model of Valentina is that it allows you to build databases using the relational model, then add object features when you are ready, much like the migration from programming in C to C++ (or C#). The main ideas behind Valentina database model are: * Data Model should reflect to real world concepts as much as possible. * The more concepts a DBMS knows and understands the better. *RDBMS: ** Table with Fields ** Views ** Triggers ** Stored Procedures ** Indexes as optimization structures *ValentinaDB adds to that: ** RecID/OID Fields - the base IDs of records to be used on all Valentina DB levels. ** “Link”abstraction of few kinds: *** ForeigkKey as link, instead as constraint. *** ObjectPtr link *** BinaryLink *** KeyValue Store - as universal store of Key-Value pairs. It can be integrated to Tables and Links. *** Properties for Tables, Fields, Links, KeyValues, i.e. to any DB Schema object. *RecID and OID **Each Valentina table have hidden RecID and OID fields. RecID gives a unique identifier of a record in the scope of a table, OID - in the scope of database. **Mature RDBMS sometimes has an analog of RecID names usually as “rowid”. OO DBMS following ODMG standard does have OID field for objects. But Valentina beat them both in implementation of this feature! Let you have table with million records. RDBMS will eat for rowid 4MB of data + about 12MB of index. Valentina for RecID eats ZERO Disk/Ram space! For OID field others use 8Mb + about 18MB index, Valentina still uses ZERO Disk/Ram space. New Abstraction "Link" Intalling #Close livecode #Intall ValentinaDB for livecode #Launch Livecode #Open the file install.rev #Close livecode Now Valentina for Livecode is installed. Examples Creating an Employee Database In order to start you should initialize Valentina with the help of Valentina_Init() function. It can be done in the openCard event, for example: on OpenCard get Valentina_Init( 10 * 1024 * 1024 ) end OpenCard on CloseCard get Valentina_ShutDown end CloseCard Firstly we have to construct the database object. It will be stored inside the plugin. After this we have to save resulting reference into some variable for further operating. And finally we write some code to open the database or to create it. local mDatabase on DatabaseCreate put VDatabase_Constructor() into mDatabase -- Build db full path near to stack: get the effective filename of this stack set the itemDel to slash put the (item 1 to -2 of it) & slash & "Database1" into dbPath get VDatabase_Open( mDatabase, dbPAth ) if VDatabase_ErrNumber(mDatabase) is not "0" then get VDatabase_Create( mDatabase, dbPAth, "kDscDatBlbInd" ) end if get VDatabase_DateFormat( mDatabase, "kYMD" ) get VDatabase_DateSep( mDatabase, "-" ) end DatabaseCreate on DatabaseClose get VDatabase_Close( mDatabase ) put VDatabase_Destructor( mDatabase ) into mDatabase end DatabaseClose We want to create the table with three fields: Name, LName, BirthDate. The similar way we constructed database we will get the reference to the created table. on CreateStructure put VDatabase_CreateTable(mDatabase, "Person") into pTable get VTable_CreateVarcharField( pTable, "Name", 1022, "fIndexed" ) get VTable_CreateVarcharField( pTable, "LName", 1022, "fIndexed" ) get VTable_CreateDateField( pTable, "BirthDate", "fIndexed" ) end CreateStructure on DatabaseCreate put VDatabase_Constructor() into mDatabase -- Build db full path near to stack: get the effective filename of this stack set the itemDel to slash put the (item 1 to -2 of it) & slash & "Database1" into dbPath get VDatabase_Open( mDatabase, dbPAth ) if VDatabase_ErrNumber(mDatabase) is not "0" then get VDatabase_Create( mDatabase, dbPAth, "kDscDatBlbInd" ) CreateStructure end if get VDatabase_DateFormat( mDatabase, "kYMD" ) get VDatabase_DateSep( mDatabase, "-" ) end DatabaseCreate At this step you will learn how to create graphic elements to control database. Add button function DoAdd put VDatabase_Table( mDatabase, "Person" ) into tblPerson get VTable_SetBlank(tblPerson) get CollectPanes() get VTable_AddRecord(tblPerson) end DoAdd Update button function DoUpdate put VDatabase_Table( mDatabase, "Person" ) into tblPerson get CollectPanes() get VTable_UpdateRecord(tblPerson) end DoUpdate Delete button function DoDelete put VDatabase_Table( mDatabase, "Person" ) into tblPerson get VTable_DeleteRecord(tblPerson) get PopulateFields() end DoDelete Collect and populate function CollectPanes put VDatabase_Table( mDatabase, "Person" ) into tblPerson put VTable_Field( tblPerson, "Name" ) into pName put VTable_Field( tblPerson, "LName" ) into pLName put VTable_Field( tblPerson, "BirthDate" ) into pBirthDate get VField_Value( pName, field efName ) get VField_Value( pLName, field efLName ) get VField_Value( pBirthDate, field efBirthDate ) end CollectPanes function PopulateFields put VDatabase_Table( mDatabase, "Person" ) into tblPerson put VTable_Field( tblPerson, "Name" ) into pName put VTable_Field( tblPerson, "LName" ) into pLName put VTable_Field( tblPerson, "BirthDate" ) into pBirthDate put VField_Value( pName ) into field efName put VField_Value( pLName ) into field efLName put VField_Value( pBirthDate ) into field efBirthDate end PopulateFields First button function DoFirst put VDatabase_Table( mDatabase, "Person" ) into tblPerson get VTable_FirstRecord(tblPerson) get PopulateFields() end DoFirst Previous button function DoPrev put VDatabase_Table( mDatabase, "Person" ) into tblPerson get VTable_PrevRecord(tblPerson) get PopulateFields() end DoPrev Next Button function DoNext put VDatabase_Table( mDatabase, "Person" ) into tblPerson get VTable_NextRecord(tblPerson) get PopulateFields() end DoNext Last button function DoLast put VDatabase_Table( mDatabase, "Person" ) into tblPerson get VTable_LastRecord(tblPerson) get PopulateFields() end DoLast Category:Database